package controllers;

import dto.retjson.RetDataDto;
import models.user.AniUser;
import play.libs.Json;
import play.mvc.Result;
import services.api.AniApiAuthService;
import services.user.AniLocalUserService;
import utils.MVCUtils;
import views.html.*;

public class AppApprovalController extends BaseController {
    public static Result userApprovalToTargetApp(Long fromAppId, Long targetAppId){
        return ok(approval.render(fromAppId, targetAppId));
    }
    public static Result acceptApprovalToTargetApp(Long fromAppId, Long targetAppId){
        try{
            AniApiAuthService.acceptApprovalToTargetApp(fromAppId, targetAppId);
        }catch (Exception e){
            return internalServerError(
                    Json.toJson(
                            new RetDataDto(
                                    false,
                                    e.getMessage()
                            )
                    )
            );
        }
        return ok(
                Json.toJson(
                        new RetDataDto(
                                true,
                                "ok"
                        )
                )
        );
    }
}
